<?php 

  require_once('nav.php'); 
?>
        <div class="col-sm-9 col-md-10">
  <?php 

$name=$_POST['uname']; 
  // var_dump($name); 
   //$sql = "select * from videos where videoname like '%{$name}%'";
   $sql="select * from users where uname like '%{$name}%'";
 // var_dump($sql);
$result=fetch_array($sql);  
//var_dump($result); 
   ?>
     <center><h3>用户列表</h3></center>
      <form method="post" action="user-search.php">

   请输入用户名：

  <input type="text" name="uname" id="uname">

  <input type="submit" name='search' value="搜索">  

 </form> 
 <table class=" table table-hover"> 
 <tr>
   <th>用户编号</th>
   <th>用户名</th>   
   <th>性别</th>
   <th>生日</th>
   <th>爱好</th>
   <th>学历</th>
   <th>自我介绍</th> 
   <th width='80'>头像</th>
   <th>操作</th>
 </tr>
 </div>
  </div>
</div>
 <?php
  foreach ($result as $row) {
   echo '<tr>';
   echo '<td>'.$row['uid'].'</td>';
   echo '<td>'.$row['uname'].'</td>';  
   echo '<td>'.($row['gender']==0?'男':'女').'</td>';
   echo '<td>'.$row['birthdate'].'</td>';
   echo '<td>'.$row['hobby'].'</td>';
   switch($row['degree']){
     case '1':$dg = "高中";break;
     case '2':$dg = "大学";break;
     case '3':$dg = "研究生";break;
     case '4':$dg = "博士生";break;
     default: $dg="不知道";
     }
   echo '<td>'.$dg.'</td>';
   echo '<td>'.$row['intro'].'</td>';    
   echo '<td align="center"><img src=../images/'.$row['pic'].' width=60 height=80></td>';  
   echo '<td><a href="useredit-form.php?id='.$row['uid'].' ">修改</a> | 
   <a href="userdelete.php?id='.$row['uid'].'" onClick="return confirm(\'确定要删除吗？\');">删除</a></td>';
   echo '</tr>';  
  }
  echo '</table>';  
  $totalrows = count($result);
  echo "<table align='center'><tr><td>共有{$totalrows}名用户</td></tr></table>";   
  ?>

    </div>
     <?php
  require_once('footer.php');
    ?>